<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>权限选择</title>
<script type="text/javascript" src="common/plugin/jquery-1.11/jquery.min.js"></script>
</head>
<body>
      是否在已有权限上添加权限?<br><br>
      <form action="PermissionServlet?flag=insertGrant" method="post">
      <input type="text" id="showFather" name="fatherPerId"/>
      <select name="grant" onchange="selectGrant()" id="grant" onblur="selectManager(this.value)">
        <option>请选择父权限</option>
        <c:forEach items="${list }" var="permission">
        <option value="${permission.permissionId }">${permission.permissionName}</option>
        </c:forEach>
      </select><br><br>
      
     请添加子权限id:(按给出的格式添加)<br>
      <input type="text" name="sonPerId"/>
      <select name="sonId" id="sonId">
       <option>按如下格式给出子id</option>
      </select>
      <br><br>
      
  请添加子权限名称:<br>
   <input type="text" name="sonName"  value="${permission.permissionName }"/><br><br>
  
  请添加url:<br>
  <input type="text" name="sonUrl" value="${permission.permissionUrl }"/><br><br>
  <input type="submit" value="新增"/>
      
   </form>

  <script type="text/javascript">
    function selectGrant(){
    	var fatherGrant = document.getElementById("grant").value;
    	 document.getElementById("showFather").value = fatherGrant;
    	/* document.forms[0].submit; */
    }
  
  </script>
  
  <script type="text/javascript">
    function selectManager(permissionId){
    	$.get("PermissionServlet?flag=grantManager&permissionId="+permissionId,function(data){
    		
    		var sonSelect = document.getElementById("sonId");
    		//清空上一次的数据
    		sonSelect.options.length = 1;
    		var sonId = data.split(","); 
    		for(var i=0;i<sonId.length;i++){
    		$("#sonId").append("<option value='sonId[i]'>"+sonId[i]+"</option>");
    		}
    	});
    }
    		
  
  </script>

</body>
</html>